﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using RacePlatformer;
using Microsoft.Xna.Framework;

namespace Dwarfs.Manager
{
    public class BackgroundManager
    {
        List<Texture2D> backgrounds;
        private MainGame maingame;
        private int levelID;
        public BackgroundManager(MainGame maingame)
        {
            this.maingame = maingame;
        }
        public void initialize(int levelID)
        {
            this.levelID = levelID;
            backgrounds = new List<Texture2D>();
            loadContent();
        }
        public void drawBackgrounds(GameTime gametime, SpriteBatch batch)
        {
            int offsetX = -1000;
            foreach (Texture2D texture in backgrounds)
            {
                batch.Draw(texture, new Rectangle(offsetX, 0, texture.Width, texture.Height), null, Color.White, 0f, new Vector2(0, 0), SpriteEffects.None, 1.0f);
                offsetX += texture.Width;
            }
        }
        public void loadContent()
        {
            backgrounds.Add(maingame.Content.Load<Texture2D>("backgrounds/level" + levelID + "/bg1"));
            backgrounds.Add(maingame.Content.Load<Texture2D>("backgrounds/level" + levelID + "/bg2"));
            backgrounds.Add(maingame.Content.Load<Texture2D>("backgrounds/level" + levelID + "/bg1"));
            backgrounds.Add(maingame.Content.Load<Texture2D>("backgrounds/level" + levelID + "/bg2"));
        }
    }
}
